﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections.Generic;
using Runda.CMS.Common.Utility;
using Runda.CMS.Common.Entity;
using Runda.CMS.Bll;
using Runda.CMS.Workflow;
using System.Text;

namespace Runda.CMS.Portal.Workspace
{
    public partial class Notice_View : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["NoticeID"] != null && Request.QueryString["NoticeID"].ToString() != "")
                {
                    NoticeID.Text = Request.QueryString["NoticeID"].ToString();
                    InitForm(NoticeID.Text);
                }

                if (Request.QueryString["readed"] != null && Request.QueryString["readed"].ToString() != "")
                {
                    List<CtrtMyNoticeUserEntity> entitys = new CtrtMyNoticeUserBll().GetAll<CtrtMyNoticeUserEntity>(" and NoticeID ='" + Request.QueryString["NoticeID"].ToString() + "' and userid='" + Session["CurrentUserID"].ToString() + "'");
                    if (entitys != null && entitys.Count > 0)
                    {
                        CtrtMyNoticeUserEntity noticeUserEntity = entitys[0];
                        noticeUserEntity.Status = System.Convert.ToInt32(Enumerator.NoticeMessageStatus.read);
                        new CtrtMyNoticeUserBll().Update(noticeUserEntity);

                    }
                }


            }
        }

        private void InitForm(String strNoticeID)
        {
            CtrtMyNoticeEntity noticeEntity = new CtrtMyNoticeBll().Get<CtrtMyNoticeEntity>(new Guid(strNoticeID));
            NoticeTime.Text = noticeEntity.NoticeTime.ToString();
            NoticeContent.InnerHtml = noticeEntity.NoticeContent;
        }
    }
}
